﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace OpenQuarters.WebQuarters.Core
{
    [ModuleConfiguration(Hidden = true)]
    public class ModuleErrorModule : Module
    {
        public enum ModuleErrorModuleError
        {
            Could_Not_Find_Module_Type,
            Exception
        }

        private ModuleErrorModuleError errorType = ModuleErrorModuleError.Could_Not_Find_Module_Type;

        [Newtonsoft.Json.JsonProperty]
        public ModuleErrorModuleError ErrorType
        {
            get { return errorType; }
            set { errorType = value; }
        }

        private string value = "";

        public string Value
        {
            get { return value; }
            set { this.value = value; }
        }

        public override void Initialise()
        {
            this.ModuleName = "Error Module";
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            this.Controls.Add(new LiteralControl("<p>" + ErrorType.ToString().Replace("_", " ") + ": " + Value + "</p>"));
        }
    }
}
